using System;
using System.Threading.Tasks;
using UnityEngine;

public class AsyncResultExample : MonoBehaviour
{
    private async void Start()
    {
        // 调用异步方法并等待结果
        int result = await CalculateAsync();
        Debug.Log($"异步计算的结果是: {result}");
    }

    private async Task<int> CalculateAsync()
    {
        // 模拟耗时操作
        await Task.Delay(2000);
        return 42;
    }
}